/*
 * readBuffer.h
 *
 *  Created on: Apr 29, 2012
 *      Author: root
 */


#ifndef READBUFFER_H_
#define READBUFFER_H_

#include	<sys/types.h>

typedef struct {
    int 	count;
    int		rear;
    int		front;
    char	*buf;
    int		bufsize;
} ReadBuffer;

ReadBuffer * createRbuf(int bufsize);
void	destroyRbuf(ReadBuffer *rbuf);
void 	initRbuf(ReadBuffer *rbuf);
ssize_t	readBuf(ReadBuffer *rbuf, int fd);
unsigned char 	getChar(ReadBuffer *rbuf);
unsigned char 	ungetChar(ReadBuffer *rbuf, unsigned char c);
char *	getString(ReadBuffer *rbuf, char *str, ssize_t len);
char *	getSuffix(ReadBuffer *rbuf, char *buf, ssize_t bufsize, char *suffix);
char *	getLine(ReadBuffer *rbuf, char *buf, ssize_t bufsize);
char *	getCRLF(ReadBuffer *rbuf, char *buf, ssize_t bufsize);
char *	getMessage(ReadBuffer *rbuf, char *buf, ssize_t bufsize);

#endif /* READBUFFER_H_ */
